<template>
  <div class="navbar">
    <router-link to="/" class="nav-item" :class="{ active: activeTab === 1 }" @click="setActiveTab(1)">
      文章管理
    </router-link>
    <router-link to="/about" class="nav-item" :class="{ active: activeTab === 2 }" @click="setActiveTab(2)">
      文章发布
    </router-link>
  </div>

  <router-view></router-view>
</template>

<script setup>
import { ref } from "vue";

const activeTab = ref(1);

function setActiveTab(index) {
  activeTab.value = index;
}
</script>

<style lang="css" scoped>
.navbar {
  width: 100%;
  height: 60px;
  display: flex;
  background-color: #2c3e50;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.nav-item {
  flex: 1;
  text-align: center;
  line-height: 60px;
  color: #ecf0f1;
  text-decoration: none;
  font-size: 18px;
  font-weight: 500;

}

.nav-item:hover {
  background-color: #34495e;
  color: #ffffff;
  transform: scale(1.05);
}

.active {
  background-color: #e74c3c;
  color: #ffffff;
  box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
  font-weight: 700;
  transform: scale(1.1);
}
</style>
